<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>消耗型办公用品列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../static/css/font.css" th:href="@{/static/css/font.css}">
    <link rel="stylesheet" href="../static/css/xadmin.css" th:href="@{/static/css/xadmin.css}">
    <script src="../static/lib/layui/layui.js" charset="utf-8" th:src="@{/static/lib/layui/layui.js}"></script>
    <script type="text/javascript" src="../static/js/xadmin.js" th:src="@{/static/js/xadmin.js}"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
         <!-- <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
              <a>
                  <cite>个人信息页面</cite>
              </a>
          </span>-->

</div>
<form class="layui-form" >



    <div class="layui-form-item">
        <label class="layui-form-label">我的姓名:</label>
        <div class="layui-input-inline">
            <!--/*@thymesVar id="userName" type=""*/-->
            <input type="text" name="username" lay-verify="required|username" class="layui-input" th:value="${user.userName}">
        </div>
    </div>


    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色类型:</label>
        <div class="layui-form-label-col">
            <p th:text="${user.userType}"></p>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">手机号:</label>
        <div class="layui-input-inline">
            <input type="text" name="phonenumber" lay-verify="required|phonenumber" class="layui-input" th:value="${user.phonenumber}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱:</label>
        <div class="layui-input-inline">
            <input type="email" name="email" lay-verify="required|email" class="layui-input" th:value="${user.email}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别:</label>
        <div class="layui-form-label-col">
            <input type="radio" name="sex" value="男" title="男" th:checked="${user.getSex()=='男'}">
            <input type="radio" name="sex" value="女" title="女" th:checked="${user.getSex()=='女'}">
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-md-offset4">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="saveBtn">保存</button>
            <!--<button class="layui-btn" ><a th:href="@{/jump/To-officelog-list}">返回</a> </button>-->
        </div>
        <!--<div class="layui-input-block">
            <button class="layui-btn" ><var url = "http://www.gsxt.gov.cn/index.html";>查询企业信息</var> </button>
        </div>-->
    </div>
</form>

<script src="/lib/layui-v2.5.4/layui.js" charset="utf-8" th:src="@{/lib/layui.js}"></script>
<script>
    layui.use(['form', 'laydate', 'upload', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            laydate = layui.laydate,
            element = layui.element,
            upload = layui.upload;
        //自定义验证规则
        form.verify({
            username: function(value){
                if(value.length == 0){
                    return '我的姓名不能为空';
                }



            }
            ,phonenumber:function (value) {
                if (value.length==0){
                    return "手机号不能为空";
                }

            }
            ,sex:function (value) {
                if (value.length==0){
                    return "性别不能为空";
                }

            }
            ,email:function (value) {
                if (value.length==0){
                    return "邮箱不能为空";
                }

            }


        });

        //监听提交
        form.on('submit(saveBtn)', function (param) {

            $.ajax({
                url: "/updatainformation",
                type: "post",
                data: {username:$('input[name="username"]').val(),phonenumber:$('input[name="phonenumber"]').val(),email:$('input[name="email"]').val(),sex:$('input[name="sex"]:checked').val()},
                success: function (rst) {
                    layer.msg(rst.msg);
                    if (rst.msg=="信息修改成功") {

                    }
                    else {
                        return "信息修改失败";
                    }
                }
            });
            return false;
        });

    });
</script>

</body>
</html>